package com.qf.day10_3;

/**
 * @author wgy
 * @version V1.0
 * @Project day10
 * @Package com.qf.day10_3
 * @Description: ${TODO}
 * @Date 2021/5/31 11:33
 */
public class Animal {
    /**
     * 昵称
     */
    private String nickname;
    /**
     * 品种
     */
    private String breed;
    /**
     * 颜色
     */
    private String color;
    /**
     * 年龄
     */
    private int age;

    /**
     * 无参构造方法
     */
    public Animal(){

    }

    /**
     * 带参构造方法
     * @param nickname 昵称
     * @param breed 品种
     * @param color 颜色
     * @param age 年龄
     */
    public Animal(String nickname, String breed, String color, int age) {
        this.nickname = nickname;
        this.breed = breed;
        this.color = color;
        this.setAge(age);
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getBreed() {
        return breed;
    }

    public void setBreed(String breed) {
        this.breed = breed;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age<1||age>10){
            this.age=2;
        }else {
            this.age = age;
        }
    }

    /**
     * 吃
     */
    public void eat(){
        System.out.println(this.nickname+"正在吃东西...");
    }

    /**
     * 打印信息
     */
    public void show(){
        System.out.println("动物信息: 昵称:"+this.nickname+" 品种:"+this.breed+" 颜色:"+this.color+" 年龄:"+this.age);
    }
}
